package ru.zhigulin.io.item.food;

import net.minecraft.component.type.FoodComponent;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
import ru.zhigulin.io.ShootAndFun;

public class MarshmallowOnStick extends Item {
    public static final Identifier ID = new Identifier(ShootAndFun.MOD_ID, "marshmallow_on_stick");

    private static final Item.Settings SETTINGS = new Item.Settings()
            .maxCount(64)
            .food(new FoodComponent.Builder().nutrition(6).saturationModifier(0.1f).build());

    public MarshmallowOnStick() {
        super(SETTINGS);
    }

    @Override
    public ItemStack finishUsing(ItemStack stack, World world, LivingEntity user) {
        if (user instanceof PlayerEntity) {
            var stick = new ItemStack(Items.STICK);
            ((PlayerEntity) user).getInventory().insertStack(stick);
        }
        return super.finishUsing(stack, world, user);
    }
}
